<template>
  <el-container class="layout-container">
    <el-header style="text-align: right; font-size: 12px">
      <div class="toolbar">
        <el-dropdown>
          <el-icon style="margin-right: 8px; margin-top: 1px">
            <setting />
          </el-icon>
          <template #dropdown>
            <el-dropdown-menu>
              <router-link to="/workstore/info" class="router-link">

                <el-dropdown-item>信息管理</el-dropdown-item>
              </router-link>
              <el-dropdown-item @click="unLogin">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <span>{{ publicStore.AdminUser.name }}</span>
        <el-avatar style="margin-left: 12px;" :size="32" :src="'http://www.cetastar.com/img/'+publicStore.AdminUser.profile_picture" />
      </div>
    </el-header>
    <el-container>
      <el-aside style="height: calc(100vh - 60px)" width="200px">
        <el-scrollbar>
          <el-menu>
            <router-link to="/workstore/home" class="router-link">
              <el-menu-item index="0">
                <template #title>
                  <el-icon><house /></el-icon>首页
                </template></el-menu-item
              ></router-link
            >
            <el-sub-menu index="1">
              <template #title>
                <el-icon><message /></el-icon>留言管理
              </template>

              <router-link to="/workstore/leavemsg" class="router-link">
                <el-menu-item index="1-1"> 留言列表</el-menu-item></router-link
              >
            </el-sub-menu>
            <el-sub-menu index="2">
              <template #title>
                <el-icon><message /></el-icon>商品管理
              </template>

              <router-link to="/workstore/goods" class="router-link">
                <el-menu-item index="2-1"> 商品列表</el-menu-item></router-link
              >
            </el-sub-menu>
          </el-menu>
        </el-scrollbar>
      </el-aside>

      <el-main style="height: calc(100vh - 60px)">
        <el-scrollbar>
          <router-view></router-view>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import { Message, Setting, House } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import { usePublicStore } from "../../stores/public";
import { adminUser, identity } from "../../stores/identity";

const router = useRouter();
router.push("/workstore/home");
const publicStore=usePublicStore()
 const unLogin=()=>{
    adminUser.adminId=""
    identity.authorization=""
    identity.isLogin=false
    adminUser.name=""
    adminUser.profile_picture=""
    publicStore.changeAdminUser(adminUser)
    router.push('/login')

}
</script>

<style scoped>
.router-link {
  text-decoration: none;
}
.layout-container {
  height: 100vh;
}
.layout-container .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}
.layout-container .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}
.layout-container .el-menu {
  border-right: none;
}
.layout-container .el-main {
  padding: 0;
}
.layout-container .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
